<template>
	<view class="page">
		<view class="head">
			<!-- #ifdef APP-PLUS -->
			<view class="title">购物车</view>
			<!-- #endif -->
			<view class="title">购物车</view>
			<view class="edit" @click="isEdit = !isEdit">
				<text>{{isEdit?'完成':'管理'}}</text>
			</view>
		</view>
		<!-- 购物车列表 -->
    <mescroll-body ref="mescrollRef"
                   @down="downCallback"
                   @up="upCallback"
                   :down="downOption"
                   :up="upOption"
                   :top="0">
		<view style="margin-top: 100rpx;"></view>
		<view v-for="(item,index) in cartList" class="cart-list">
<!-- 			<view  style="height:50px;" class="list"> -->
<!-- 				<view class="check"> -->
<!-- 					<text @click="checkAll(index)" :class="item.check ? 'icon-checked' : 'icon-check'" class="iconfont "></text> -->
<!-- 				  </view>					 
				</view> -->
<!-- 				<view class="store-info">{{item.name}}</view> -->
<!-- 			</view> -->
			<view v-for="(item1,index1) in item.goodslist" class="list">		
				<view class="goods">
				    <view @click="check(index,index1)" class="check">
	                   <view class="icon">
					    <image   :src="item1.check ? '/static/icon/gouxuan.png' : '/static/icon/weigouxuan.png'"  mode="">							
						</image>
					    </view>	
				    </view>					
					<view class="thumb">
						<image :src="item1.src" mode=""></image>
					</view>
					<view class="item">
						<view class="title">
							<text class="two-omit">{{item1.name}}</text>
						</view>
						<view class="attribute">
							<view class="attr">
								<text>规格:{{item1.norms_name||'测试型号'}}</text>
<!-- 								<text class="more"></text> -->
							</view>
						</view>
						<view class="price-num">
							<view class="price">
								<text class="selling-price">￥{{item1.price}}</text>
								<text class="original-price">￥{{item1.cost||500}}</text>
							</view>
							<view  class="num">
								<view @click="desc(index,index1)" class="add">
				                  <view class="icon">
					                <image  :src="OSS_HOST+'icon/jianhao.png'"  mode=""></image>
			                      </view>
								</view>
								<view class="number">
									<text>{{item1.number}}</text>
								</view>
								<view  @click="add(index,index1)" class="add">
									<view class="icon">
									  <image  :src="OSS_HOST+'icon/jiahao.png'"  mode=""></image>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			
		</view>
    <!-- 购物车失效商品列表 -->
    <!-- <view class="lose-efficacy-list">
      <view class="lose-efficacy-title">
        <view class="title">
          <text>失效商品1件</text>
        </view>
        <view class="empty">
          <text>清空失效商品</text>
        </view>
      </view>
      <view class="list" v-for="(item,index) in 2" :key="index">
        <view class="tag">
          <text>失效</text>
        </view>
        <view class="goods" @click="onSkip('goods')">
          <view class="pictrue">
            <image :src="'/static/img/goods_thumb_0'+ (index+1) +'.png'" mode=""></image>
          </view>
          <view class="item">
            <view class="title">
              <text class="two-omit">薇妮(Viney)时尚包包女包牛皮单肩包女休闲百搭斜挎包韩版小方包潮(水电费枪色)</text>
            </view>
            <view class="explain">
              <text>商品已不能购买，请联系客服进行沟通</text>
            </view>
          </view>
        </view>
      </view>
    </view> -->
    <!-- 为你推荐 -->
   <!-- <view class="recommend-info">
      <view class="recommend-title">
        <view class="title">
          <image src="/static/wntj_title.png" mode=""></image>
        </view>
      </view>
      <view class="goods-list">
        <view class="list" v-for="(item,index) in goodsList" @click="onSkip('goods')" :key="index">
          <view class="pictrue">
            <image :src="item.img" mode="heightFix"></image>
          </view>
          <view class="title-tag">
            <view class="tag">
              <text v-if="item.is_goods === 1">特价</text>
              {{item.name}}
            </view>
          </view>
          <view class="price-info">
            <view class="user-price">
              <text class="min">￥</text>
              <text class="max">{{item.price}}</text>
            </view>
            <view class="vip-price">
              <image src="/static/vip_ico.png"></image>
              <text>￥{{item.vip_price}}</text>
            </view>
          </view>
        </view>
      </view>
    </view> -->
		<!-- 结算 -->
		<view class="close-account">
			<view class="check-total">
				<!-- <view class="check">
					<text class="iconfont icon-check"></text>
					<text class="all">全选</text>
				</view> -->
				<view style="padding-left:15px;" class="total" v-if="!isEdit">
					<text>合计：</text>
					<text class="price">￥{{payAmount}}</text>
				</view>
				<view style="padding-left:15px;" class="total" v-else>
					<text>已选</text>
					<text class="price">{{typenum}}项</text>
				</view>
			</view>
			<view class="account">
				<view @click="pay" class="btn-calculate" v-if="!isEdit">
					<text>去结算</text>
				</view>
				<view class="btn-calculate" v-else>
					<!-- <text class="attention">移入关注</text> -->
					<text @click="toDel" >删除</text>
				</view>
			</view>
		</view>
    </mescroll-body>
		<!-- tabbar -->
		<TabBar :tabBarShow="2"></TabBar>
		<uni-popup ref="delModel" type="center" custom="true" >
			<view class="del-tab">
				<view class="content">
					确认清除商品！
				</view>
				<view class="btn">
					<view class="btn-border" @tap="$refs['delModel'].close()">取消</view>
					<view class="btn-border btn-queren" @tap="del">确认</view>
					
				</view>
			</view>	
			
		</uni-popup>
		<uni-popup-vlogin id="popupvLogin" ref="popupvLogin" type="bottom" />	
		<goods-list ref="GoodsList"></goods-list>
	</view>
</template>

<script>
	import Vue from 'vue';
	import TabBar from '../../components/TabBar/TabBar.vue';
	import cart from '@/utils/cartshop.js' 
	import {oss_host} from '@/config/config.js';
	import GoodsList from '../../components/GoodsList/GoodsList.vue';
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
  // 引入mescroll-mixins.js
  import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
	components: {
		uniPopup,
		GoodsList
	},
    mixins: [MescrollMixin], // 使用mixin
		components:{
			TabBar,
		},
		watch:{
			payCartList:{
				handler(newGoodslist,oldval){
					console.log('watch payCartList change')
					this.payAmount = 0
					this.typenum = 0
					for(let key in newGoodslist){
						this.cartList[key].check = newGoodslist[key].check
						for(let key1 in newGoodslist[key].goodslist){
							this.payAmount += (newGoodslist[key].goodslist[key1].price*newGoodslist[key].goodslist[key1].number)				
							this.cartList[key].goodslist[key1].check = true
							this.typenum=this.typenum+1
						}
					}
				}
			},
			immediate:true,
			deep:true
		},
		data() {
			return {
	    OSS_HOST: oss_host,
        mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
        // 下拉刷新的配置(可选, 绝大部分情况无需配置)
        downOption: {},
		isDrawer:false,
        // 上拉加载的配置(可选, 绝大部分情况无需配置)
        upOption: {
          use: false,
          toTop: {
            src: '',
          }
        },
		// cart:{
		// 	10:{
		// 		name:'xxxxx门店',
		// 		goodslist:{
		// 			norms_value_id:{
		// 				product_id,
		// 				name:'xxx产品',
		// 				norms_name:'金色,大尺码',
		// 				price:89.00,
		// 				number:2,
		// 				src:''
		// 			}
		// 		}
		// 	}
		// },
		cartList:{},//购物车列表
		payCartList:{},//支付列表||删除列表
		payAmount:0,
		typenum:0,
		isEdit: false,
		isgoto:'Y',
        goodsList:[
          {
            id: 1,
            name: 'BANDALY 2020夏季女装连衣裙韩版大码宽松显瘦套装裙子两件套 JX19301 上豆绿下米白 M ',
            price: '219.00',
            vip_price: '129.00',
            img: '/static/img/goods_thumb_01.png',
            is_goods: 0,
          },{
            id: 1,
            name: '花花公子 卫衣男秋季圆领薄款休闲体恤男士时尚长袖T恤外套上衣男生情侣装套头衣服秋天男装 白色 XL',
            price: '139.00',
            vip_price: '99.00',
            img: '/static/img/goods_thumb_02.png',
            is_goods: 1,
          },{
            id: 1,
            name: '【两件套】花花公子PLAYBOY短袖T恤男套装夏季新款卫衣男士韩版修身冰丝宽松运动休闲上衣服裤子男装 CYFS903卡其色 XL',
            price: '168.00',
            vip_price: '158.00',
            img: '/static/img/goods_thumb_03.png',
            is_goods: 1,
          },{
            id: 1,
            name: '雪域森林短袖T恤男装2020夏季潮流时尚衣服男潮牌圆领印花宽松T恤半袖男 20855橙色 XL',
            price: '68.00',
            vip_price: '36.00',
            img: '/static/img/goods_thumb_04.png',
            is_goods: 0,
          },{
            id: 1,
            name: '短袖男夏季T恤男装韩版潮流印花套头衣服男士圆领宽松五分袖学生休闲夏天运动时尚情侣装大码 D119白色 XL',
            price: '68.00',
            vip_price: '59.00',
            img: '/static/img/goods_thumb_05.png',
            is_goods: 0,
          },{
            id: 1,
            name: '时尚休闲套装女夏季热天宽松女孩中学生高中初中生女生短袖套装衣服夏天少女学生韩版原宿风T恤潮流裤子一套 绿字母上衣+绿色裤两件套 均码',
            price: '83.00',
            vip_price: '78.00',
            img: '/static/img/goods_thumb_06.png',
            is_goods: 1,
          },{
            id: 1,
            name: '北极绒2020春夏季棉质睡衣女睡裙女夏季韩版纯棉短袖少女性感睡衣甜美可爱卡通家居服连衣裙 A3023 M【纯棉 品质保障】',
            price: '68.00',
            vip_price: '48.00',
            img: '/static/img/goods_thumb_07.png',
            is_goods: 1,
          },{
            id: 1,
            name: '韩卡婷 2020新款夏季短袖t恤女宽松学生衣服原宿风青春百搭显瘦上衣体恤闺蜜女装 白色 均码【80-120斤】',
            price: '29.00',
            vip_price: '19.00',
            img: '/static/img/goods_thumb_08.png',
            is_goods: 0,
          },{
            id: 1,
            name: '美连诚雪纺连衣裙 2020新款女夏裙子波点气质沙滩裙仙气时尚女装休闲衣服大码女装 白底红点 M ',
            price: '168.00',
            vip_price: '160.00',
            img: '/static/img/goods_thumb_09.png',
            is_goods: 0,
          },{
            id: 1,
            name: '凝拉t恤女短袖纯棉2020新款夏装中长款韩版宽松大码欧货潮上衣服半袖体恤 桔色2053 2XL（建议150-170斤)',
            price: '89.00',
            vip_price: '78.00',
            img: '/static/img/goods_thumb_10.png',
            is_goods: 0,
          },{
            id: 1,
            name: '荣耀Play4T 全网通6GB+128GB大内存 幻夜黑 4000mAh大电池 4800万AI摄影  6.39英寸魅眼屏',
            price: '1190.00',
            vip_price: '1100.00',
            img: '/static/img/goods_thumb_11.png',
            is_goods: 0,
          },{
            id: 1,
            name: '小米（MI） Redmi 8A',
            price: '699.00',
            vip_price: '599.00',
            img: '/static/img/goods_thumb_12.png',
            is_goods: 0,
          },{
            id: 1,
            name: 'Apple iPhone 11',
            price: '5899.00',
            vip_price: '5800.00',
            img: '/static/img/goods_thumb_13.png',
            is_goods: 0,
          },{
            id: 1,
            name: '戴尔(DELL)成就3681英特尔酷睿i5商用办公高性能台式机电脑整机(十代i5-10400 8G 1T 三年上门售后)21.5英寸',
            price: '3699.00',
            vip_price: '3600.00',
            img: '/static/img/goods_thumb_14.png',
            is_goods: 0,
          },{
            id: 1,
            name: '戴尔DELL灵越5000 14英寸酷睿i5网课学习轻薄笔记本电脑(十代i5-1035G1 8G 512G MX230 2G独显)银',
            price: '4888.00',
            vip_price: '4999.00',
            img: '/static/img/goods_thumb_15.png',
            is_goods: 0,
          },{
            id: 1,
            name: '联想(Lenovo) 来酷 Lecoo一体台式机电脑23英寸(J4105 8G 256G SSD 三年上门）白',
            price: '4888.00',
            vip_price: '3600.00',
            img: '/static/img/goods_thumb_16.png',
            is_goods: 0,
          },{
            id: 1,
            name: 'Apple 2020新款 MacBook Pro 13.3【带触控栏】十代i5 16G 512G 2.0GHz 深空灰 笔记本电脑 轻薄本 MWP42CHA',
            price: '18200.00',
            vip_price: '18200.00',
            img: '/static/img/goods_thumb_17.png',
            is_goods: 0,
          },{
            id: 1,
            name: 'Apple新款 Mac mini台式电脑主机 八代i5 8G 512G SSD 台式机 MXNG2CHA',
            price: '8299.00',
            vip_price: '8200.00',
            img: '/static/img/goods_thumb_18.png',
            is_goods: 0,
          },{
            id: 1,
            name: '同仁堂美白祛斑霜套装 淡斑美白祛黄提亮补水保湿套装 男女士护肤美白化妆品套装',
            price: '288.00',
            vip_price: '282.00',
            img: '/static/img/goods_thumb_19.png',
            is_goods: 0,
          },{
            id: 1,
            name: '【限定款·雕花口红8支礼盒装】中国风口红套装七夕礼物送女朋友老婆生日礼物唇膏唇釉花仙西子同心锁口红 【限定款8支雕花口红】',
            price: '188.00',
            vip_price: '99.00',
            img: '/static/img/goods_thumb_20.png',
            is_goods: 0,
          },
        ],
			};
		},
		onReady() {
		
      uni.hideTabBar()
		},
		created() {
		// 	let goods = {product_id:1,norms_value_id:1,store_id:1,store_name:'测试1号门店',product_name:'布洛分',norms_name:'5盒装',price:20,number:1,src:'/static/img/goods_thumb_09.png'}
		// 	let list = cart.add(goods,{},(res)=>{
		// 		 console.log(res)
		// 	});
		// 	console.log('list:',list)
		// 	list = cart.add(goods,list,function(res){
		// 		 console.log(res)
		// 	});
		// 	let goods1 = {product_id:1,norms_value_id:2,store_id:1,store_name:'测试1号门店',product_name:'布洛分',norms_name:'10盒装',price:40,number:1,src:'/static/img/goods_thumb_09.png'}
		// 	list =cart.add(goods1,list,function(res){
		// 		 console.log(res)
		// 	});
		
		// 	let goods2 = {product_id:2,norms_value_id:2,store_id:2,store_name:'测试2号门店',product_name:'葡萄',norms_name:'5斤装',price:20,number:1,src:'/static/img/goods_thumb_09.png'}
		// 	list =cart.add(goods2,list,function(res){
		// 		 console.log(res)
		// 		 uni.setStorageSync('cartList',JSON.stringify(res.data.cartList))
		// 	});
		// 	this.cartList = uni.getStorageSync('cartList')==''?{}:JSON.parse(uni.getStorageSync('cartList'))
		// 	this.payCartList = uni.getStorageSync('payCartList')==''?{}:JSON.parse(uni.getStorageSync('payCartList'))
		

			// console.log(this.payCartList)	
			//  console.log('cartList',this.cartList)

			 // this.cartList[1].check = true
			// let goods3 = {norms_value_id:1,store_id:1}  desc
			// list =cart.desc(goods3,list,function(res){
			// 	 console.log('desc',res)
			// });
			
			// cart.desc(goods3,list,function(res){
			// 	 console.log('desc1',res)
			// });
		
		},
		onLoad(e){
			this.cartList = uni.getStorageSync('cartList')==''?{}:JSON.parse(uni.getStorageSync('cartList'))
			this.payCartList = uni.getStorageSync('payCartList')==''?{}:JSON.parse(uni.getStorageSync('payCartList'))
					 console.log(this.cartList[1].check)
			 // console.log(this.payCartList)	
			 // console.log('cartList',this.cartList)
		},
    methods:{
      /*下拉刷新的回调, 有三种处理方式:*/
      downCallback(){
		
        // this.MeScroll.endSuccess();
      },
      /*上拉加载的回调*/
      upCallback(page) {
        setTimeout(() =>{
          this.MeScroll.endByPage(10, 20);
        },2000)
      },
      /**
       * 跳转点击
       * @param {String} type 跳转类型
       */
      onSkip(type){
        switch (type){
          case 'classify':
            uni.navigateTo({
              url: '/pages/SearchGoodsList/SearchGoodsList',
            })
            break;
          case 'goods':
            uni.navigateTo({
              url: '/pages/GoodsDetails/GoodsDetails',
              animationType: 'zoom-fade-out',
              animationDuration: 200
            })
            break;
        }
      },
	  //门店的商品全选
	  checkAll(storeKey){
		    let _this = this
		    this.cartList[storeKey].check = !this.cartList[storeKey].check
			// console.log(uni.getStorageSync('payCartList'))
			this.payCartList = uni.getStorageSync('payCartList')==''?{}:JSON.parse(uni.getStorageSync('payCartList'))
	  		if(this.cartList[storeKey].check)
			{
				//门店里的商品进预选购物车
				for(let key in this.cartList[storeKey].goodslist){
					if(this.cartList[storeKey].goodslist[key].check==true)
					{
						continue;
					}
					this.cartList[storeKey].goodslist[key].check = this.cartList[storeKey].check
					
						let goods = {
							product_id:this.cartList[storeKey].goodslist[key].product_id,
							norms_value_id:key,
							store_id:storeKey,
							store_name:this.cartList[storeKey].name,
							product_name:this.cartList[storeKey].goodslist[key].name,
							norms_name:this.cartList[storeKey].goodslist[key].norms_name,
							price:this.cartList[storeKey].goodslist[key].price,
							number:this.cartList[storeKey].goodslist[key].number,
							src:this.cartList[storeKey].goodslist[key].src
							}
					
						cart.add(goods,_this.payCartList,(res)=>{
							res.data.cartList[storeKey].check = true
							uni.setStorageSync('payCartList',JSON.stringify(res.data.cartList))
							_this.payCartList = res.data.cartList
						});
				}
				
				
			
			}else{
				//预选购物车删除门店商品
				for(let key in this.cartList[storeKey].goodslist){
				
					this.cartList[storeKey].goodslist[key].check = this.cartList[storeKey].check
					//删除预选
					let goods = {norms_value_id:key,store_id:storeKey}  
					cart.delProd(goods,_this.payCartList,(res)=>{
						uni.setStorageSync('payCartList',JSON.stringify(res.data.cartList))
						_this.payCartList = res.data.cartList
					});
				}
			}
			
			// console.log('all全选反选:',this.payCartList)
	  },
	  //单选商品
	  check(storeKey,goodsKey){
		  let _this = this
		  this.cartList[storeKey].goodslist[goodsKey].check = !this.cartList[storeKey].goodslist[goodsKey].check 
		  this.payCartList = uni.getStorageSync('payCartList')==''?{}:JSON.parse(uni.getStorageSync('payCartList'))
		  if(this.cartList[storeKey].goodslist[goodsKey].check)
		  {
			  let sign = true
			  for(let key in this.cartList[storeKey].goodslist){
				
				if(this.cartList[storeKey].goodslist[key].check == false){
					this.cartList[storeKey].check = false
					sign = false
					break;
				}
			  	  
			  }
			  
			  if(sign)
			  {
				  this.cartList[storeKey].check = true
			  }
			  //新增至预购
			  let goods = {
			  	product_id:this.cartList[storeKey].goodslist[goodsKey].product_id,
			  	norms_value_id:goodsKey,
			  	store_id:storeKey,
			  	store_name:this.cartList[storeKey].name,
			  	product_name:this.cartList[storeKey].goodslist[goodsKey].name,
			  	norms_name:this.cartList[storeKey].goodslist[goodsKey].norms_name,
			  	price:this.cartList[storeKey].goodslist[goodsKey].price,
			  	number:this.cartList[storeKey].goodslist[goodsKey].number,
			  	src:this.cartList[storeKey].goodslist[goodsKey].src
			  	}
			  					
			  cart.add(goods,_this.payCartList,(res)=>{
				  if(this.cartList[storeKey].check)
				  {
					res.data.cartList[storeKey].check = this.cartList[storeKey].check 
				  }
							
			  	uni.setStorageSync('payCartList',JSON.stringify(res.data.cartList))
			  	_this.payCartList = res.data.cartList
			  });
			  
		  }else{
			  this.cartList[storeKey].check = false
			  //删除预选
			  let goods = {norms_value_id:goodsKey,store_id:storeKey}  
			
			  cart.delProd(goods,_this.payCartList,(res)=>{
				  // console.log(res)
				  if(JSON.stringify(res.data.cartList) !=='{}'&&res.data.cartList[storeKey] instanceof Object)
				  {
					  res.data.cartList[storeKey].check = false
				  }
					
				  
			  	uni.setStorageSync('payCartList',JSON.stringify(res.data.cartList))
			  	_this.payCartList = res.data.cartList
			  });
		  }
		  
		  // console.log('check单选:',this.payCartList)
	  },
	  toDel(){
		  this.$refs['delModel'].open()
	  },
	 //删除购物车商品
	   del(){
		
		   let _this = this
		  
		   
		   let payCartList = uni.getStorageSync('payCartList')==''?{}:JSON.parse(uni.getStorageSync('payCartList'))
		
		    for(let storeKey in payCartList)
			{
				for(let goodsKey in  payCartList[storeKey].goodslist)
				{
					//删除购物车商品
					let goods = {norms_value_id:goodsKey,store_id:storeKey}  
					
					cart.delProd(goods,_this.cartList,function(res){
						uni.setStorageSync('cartList',JSON.stringify(res.data.cartList))
						_this.cartList = res.data.cartList
					});
				}
			}	
			uni.setStorageSync('payCartList',JSON.stringify({}))
			this.payCartList = {}
			this.$refs['delModel'].close()
			
	   },
	   
	   add(storeKey,goodsKey){
		   let _this = this
		   //新增至预购
		   let goods = {
		   	product_id:this.cartList[storeKey].goodslist[goodsKey].product_id,
		   	norms_value_id:goodsKey,
		   	store_id:storeKey,
		   	store_name:this.cartList[storeKey].name,
		   	product_name:this.cartList[storeKey].goodslist[goodsKey].name,
		   	norms_name:this.cartList[storeKey].goodslist[goodsKey].norms_name,
		   	price:this.cartList[storeKey].goodslist[goodsKey].price,
		   	number:this.cartList[storeKey].goodslist[goodsKey].number,
		   	src:this.cartList[storeKey].goodslist[goodsKey].src
		   	}
		   	if(_this.cartList[storeKey].goodslist[goodsKey].check)
		   	{
		   				   cart.add(goods,_this.payCartList,(res)=>{
		   					uni.setStorageSync('payCartList',JSON.stringify(res.data.cartList))
							
		   					_this.payCartList = JSON.parse(JSON.stringify(res.data.cartList))
							
		   				   });
		   	}				
		   cart.add(goods,_this.cartList,(res)=>{
				_this.cartList = JSON.parse(JSON.stringify(res.data.cartList))
				// Vue.set(_this.cartList[storeKey].goodslist[goodsKey],'number',res.data.cartList[storeKey].goodslist[goodsKey].number)
				for(let key in res.data.cartList)
				{
					res.data.cartList[key].check =false
					for(let key1 in res.data.cartList[key].goodslist)
					{
						res.data.cartList[key].goodslist[key1].check =false
					}
					
				}
				uni.setStorageSync('cartList',JSON.stringify(res.data.cartList))
				
				
		   });
		   
		   // console.log('add111 cartList',_this.cartList)
		   //  console.log('add222 payCartList',_this.payCartList)
			this.$forceUpdate() 
	   },
	   desc(storeKey,goodsKey){
		   let _this = this
		   let goods = {norms_value_id:goodsKey,store_id:storeKey}
		   	
			if(_this.cartList[storeKey].goodslist[goodsKey].check)
			{
				cart.desc(goods,_this.payCartList,function(res){
								uni.setStorageSync('payCartList',JSON.stringify(res.data.cartList))
								_this.payCartList = JSON.parse(JSON.stringify(res.data.cartList))
				});
			}
					
		   cart.desc(goods,_this.cartList,function(res){
			   _this.cartList = JSON.parse(JSON.stringify(res.data.cartList))
			   for(let key in res.data.cartList)
			   {
			   	res.data.cartList[key].check =false
			   	for(let key1 in res.data.cartList[key].goodslist)
			   	{
			   		res.data.cartList[key].goodslist[key1].check =false
			   	}
			   	
			   }
				uni.setStorageSync('cartList',JSON.stringify(res.data.cartList))
				
				
		   });
			
			
			
			// console.log('desc cartList',_this.cartList)
			//  console.log('desc payCartList',_this.payCartList)
			 this.$forceUpdate()  
	   },
	   pay(){
		 let _this = this
		 //判断是否处方药。由于不知道该属性字段，故先使用数量进行判断
		 for(let key in this.payCartList)
		 {		 	
		 	for(let key1 in this.payCartList[key].goodslist)
		 	{
	           if(this.payCartList[key].goodslist[key1].number===2){
				   this.$refs['GoodsList'].show()
				   this.isgoto='N'
			   }else{
				   this.isgoto='Y'
			   }
		 	}
		 	
		 }
		 
			console.log(this.payCartList)
		   if(JSON.stringify(this.payCartList)==='{}')
		   {
			   console.log('请选择商品')
			   return
		   }
		   
		   console.log('支付')
		   // product:'[{"id":"67","norms_value_id":97,"num":1},{"id":"69","norms_value_id":99,"num":2}]'
		   let goodsRequest = {product:[]}
		   for(let key in this.payCartList)
		   {
		   	
		   	for(let key1 in this.payCartList[key].goodslist)
		   	{
		   		let goods = {
								id:this.payCartList[key].goodslist[key1].product_id,
								norms_value_id:key1,
								num:this.payCartList[key].goodslist[key1].number,
								store_id:this.payCartList[key].goodslist[key1].store_id,
								product_id:this.payCartList[key].goodslist[key1].product_id,
								product_name:this.payCartList[key].goodslist[key1].name,
								price:this.payCartList[key].goodslist[key1].price,
								cover_image:this.payCartList[key].goodslist[key1].src,
							}
							
				goodsRequest.product.push(goods)	
		   	}
		   	
		   }
		   if(this.isgoto==='Y'){
			   _this.$refer.setVilit('/pages/PayOrder/submit_order')
			   let callback = function(url) {
			   	_this.$refs.popupvLogin.open()
			   }
			   let data = {
			   	product:JSON.stringify(goodsRequest.product),
			   			type:'cart',
			   	
			   }
			   _this.$refer.toUrl(callback, data)
			   
		   }
		   
		   // console.log(goodsRequest)
	   }
	}
	}
</script>

<style scoped lang="scss">
	@import 'cart.scss';
</style>
